<?php
Class Data_User extends Data_Base{

    /**
	 * 表名
	 *
	 * @var string
	 */
    static $table = 'user';
    /**
	 * 主键
	 * 
	 * @var  int
	 */
    static $primaryKey = 'id';
    /**
	 * 软删除标记
	 *
	 * @var int
	 */
    static $delflag = 'is_del';

    /**
	 * 构造函数
	 * 
	 * @access public
	 * @return void
	 */
    public function __construct() {
        parent::__construct ();
        parent::$table = self::$table;
        parent::$primaryKey = self::$primaryKey;
    }

    //获得全部队伍数据
    function getAllUser(){
        $sql	= "SELECT * FROM `user`";
        $datas	= $this->get_sql($sql);
        return $datas;
    }

    //获得全部队伍数据
    function checkTeamId($teamid){
        $sql	= sprintf("SELECT id FROM `user` WHERE `teamid`='%s'",$teamid);
        $datas	= $this->get_sql($sql);
        return $datas;
    }

    //获得全部队伍数据
    function getUser($email){
        $sql	= sprintf("SELECT * FROM `user` WHERE `email`='%s'",$email);
        $datas	= $this->get_sql($sql);
        return $datas;
    }
    //获得用户根据筛选条件
    function getUserFilter($filter){
        if($filter){
            $where = ' WHERE';
            foreach ($filter as $key=>$per){
                $where .= sprintf(" `%s`='%s' AND",$key,$per);
            }
        }
        $where = rtrim($where,'WHERE');
        $where = trim($where,'AND');
        $sql	= sprintf("SELECT * FROM `user` %s",$where);
        $datas	= $this->get_sql($sql);
        return $datas;
    }
}